<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<%@ include file="/common/taglibs.jsp" %>
<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<html>
<head>
    <title>用户Oauth授权</title>

    <script type="text/javascript" src="http://yui.yahooapis.com/2.9.0/build/uploader/uploader-min.js"></script>
    <script type="text/javascript" src="/static/scripts/user/user.edit.js"></script>

    <script type="text/javascript" src="/static/scripts/timepicker/js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="/static/scripts/timepicker/js/jquery-ui-1.8.16.custom.min.js"></script>
    <script type="text/javascript" src="/static/scripts/timepicker/js/jquery-ui-sliderAccess.js"></script>
    <script type="text/javascript" src="/static/scripts/timepicker/js/jquery-ui-timepicker-addon.js"></script>
    <link type="text/css" rel="stylesheet" href="/static/scripts/timepicker/js/jquery-ui-timepicker-addon.css"/>
    <link type="text/css" rel="stylesheet"
          href="/static/scripts/timepicker/css/ui-lightness/jquery-ui-1.8.16.custom.css"/>

    <script type="text/javascript">
        YAHOO.util.Event.onDOMReady(function () {
            var processOauth = function () {
                var Dom = YAHOO.util.Dom,
                        Event = YAHOO.util.Event;
                var username = Dom.get("username").value;
                var password = Dom.get("password").value;
                if (username != "" && password != "") {
                    YAHOO.util.Connect.asyncRequest(
                            'POST',
                            '/admin/user/token',
                            {
                                success:function (o) {
                                    if (o.responseText != "") {
                                        alert(o.responseText);
                                        Dom.get("oauth_token").innerHTML = o.responseText;
                                    }
                                },
                                failure:function (o) {
                                    alert(o.statusText);
                                },
                                scope:this
                            }, "username="+username+"&password="+password
                    );
                }

            };
            var oauth_btn = new YAHOO.widget.Button("oauth_btn", { onclick: { fn: processOauth } });
        });
    </script>
</head>
<body>
<div class="yui-g">
<input type="hidden" id="image_server_root" value="${image_server_root}">

<fieldset>
<legend>用户Oauth授权</legend>
<div>

<div id="new-user-div" class="edit-panel">
<form:form commandName="user" method="post" action="/admin/user/token" id="userForm"
           enctype="multipart/form-data">
<form:hidden path="id" id="id"/>
<table cellspacing="0" class="yui-skin-sam noborder_table" style="width: 100%">
    <tr>
        <td><label for="username">用户名:</label></td>
        <td>
            <form:input path="username" id="username" name="username" size="12" readonly="true"/>
        </td>
        <td><label for="password">密码:</label></td>
        <td>
            <input id="password" name="password" size="12"/>
        </td>
    </tr>
    <tr>
        <td colspan="4">
            <input type="button" id="oauth_btn" value="Generate Oauth Token">
        </td>
    </tr>
    <tr>
        <td colspan="2">
            OAuth Token:
        </td>
        <td colspan="2">
            <span id="oauth_token"></span>
        </td>
    </tr>
</table>
</form:form>

</div>
</div>
</fieldset>
</div>

</body>
</html>
